package export.monster
{
	import base.BaseMonster;
	
	import com.game.data.constant.FrameRate;
	
	import com.game.manager.AnimationManager;
	import com.greensock.TweenMax;
	
	import dragonBones.objects.Frame;
	
	import export.bullet.EnemyMoveBullet;
	import export.bullet.FollowTargetBullet;
	
	import export.bullet.RegionBullet;
	
	import flash.geom.Point;
	
	import flash.geom.Rectangle;
	
	
	public class Monster305 extends BaseMonster
	{
		public function Monster305()
		{
			super();
		}
		
		override protected function initBBDC():void
		{
			bbdc = AnimationManager.getAnimation("Monster305Action");
			bbdc.setAction("idle");
			bbdc.turnRight();
			bbdc.addCallBack(onEnterFrame, onActionOver);
			bodyContainer.addChild(bbdc);
		}
		
		override protected function initCollideArea():void
		{
			collideBox = new Rectangle(-40,-115,80,115);
			super.initCollideArea();
		}
		
		override protected function initAttribute():void
		{
			super.initAttribute();
			mavo.attackRange = 150;
		}
		
		override protected function onEnterFrame(action:String, frameCount:int):void
		{
			switch (action)
			{
				case "attack1":
					if(frameCount == 9 || frameCount == 21)
					{
						var b:RegionBullet = new RegionBullet();
						b.setOwner(this);
						b.setHurt(getActionHurt("attack1"));
						b.setDirect(bbdc.getDirect());
						b.setCollideArea(0,-50,125 * bbdc.getDirect(),60);
						b.setAction("Monster305Attack1");
						b.setDestroyInCount(4);
						gc.gameScene.addChild(b);
						magicBulletArray.push(b);
					}
					break;
				case "skill1":
					if(frameCount == 13)
					{
						var bu:EnemyMoveBullet = new EnemyMoveBullet("Monster305Bullet1");
						bu.setOwner(this);
						bu.setHurt(getActionHurt("skill1"));
						bu.setAction("Monster305Skill1");
						bu.setDirect(bbdc.getDirect());
						bu.setIsDestroyWhenLastFrame(true);
						bu.setSpeed(0,0);
						if(hasTarget())
						{
							bu.setPosition(curAttackTarget.getCollideCenter().x, curAttackTarget.getCollideArea().bottom);
						}
						else
						{
							bu.setPosition(getCollideCenter().x, getCollideArea().bottom);
						}
						gc.gameScene.addChild(bu);
						magicBulletArray.push(bu);
					}
					break;
				case "skill2":
					if(frameCount == 1)
					{
						var follow:FollowTargetBullet = new FollowTargetBullet("Monster305Bullet2_1");
						follow.setOwner(this);
						follow.setHurt(getActionHurt("skill2"));
						follow.setAction("Monster305Skill2");
						follow.setClipOffset(0,-getCollideArea().height);
						follow.setDirect(bbdc.getDirect());
						follow.setDestroyInCount(FrameRate.ANIMATE_FRAME_RATE * 5);
						follow.setDisable();
						gc.gameScene.addChild(follow);
						magicBulletArray.push(follow);
						for (var i:int = 1; i <= 5; i++)
						{
							TweenMax.delayedCall(i, emitSword);
						}
					}
			}
		}
		
		private function emitSword():void
		{
			for (var i:int = 0; i < 6; i++)
			{
				var bu:EnemyMoveBullet = new EnemyMoveBullet("Monster305Bullet2_2");
				bu.setOwner(this);
				bu.setHurt(getActionHurt("skill2"));
				bu.setAction("Monster305Skill2");
				bu.setDirect(bbdc.getDirect());
				var speed:int = 20;
				var horizonSpeed:int = speed * Math.cos(i * 2 * Math.PI / 6);
				var verticalSpeed:int = speed * Math.sin(i * 2 * Math.PI / 6);
				bu.setSpeed(horizonSpeed, verticalSpeed);
				bu.setDistance(1000);
				bu.setPosition(getCollideCenter().x, getCollideCenter().y);
				gc.gameScene.addChild(bu);
				magicBulletArray.push(bu);
			}
		}
		
		
		override protected function beforeSkill1Start():Boolean
		{
			return this.hasTarget() && AUtils.GetDisBetweenTwoObj(this, this.curAttackTarget) < 300;
		}
		
		override protected function beforeSkill2Start():Boolean
		{
			return this.hasTarget() && AUtils.GetDisBetweenTwoObj(this,this.curAttackTarget) < 500;
		}
	}
}
/*
package export.monster
{
	import base.BaseBitmapDataClip;
	import base.BaseBitmapDataPool;
	import base.BaseBullet;
	import base.BaseMonster;
	
	import com.dusk.util.McUtil;
	import com.dusk.util.ResUtil;
	
	import export.bullet.EnemyMoveBullet;
	import export.bullet.FollowTargetBullet;
	import export.bullet.SpecialEffectBullet;
	
	import flash.display.Sprite;
	import flash.geom.Point;
	
	public class Monster305 extends BaseMonster
	{
		private var _n:String = "小龙女";
		
		public function Monster305()
		{
			super();
			this.horizonSpeed = 7;
			this.attackBackInfoDict["hit1"] = {
				"hitMaxCount"    : 99,
				"attackBackSpeed": [0, -5],
				"attackInterval" : 24,
				"power"          : 700,
				"attackKind"     : "physics"
			};
			this.attackBackInfoDict["hit2_1"] = {
				"hitMaxCount"    : 99,
				"attackBackSpeed": [-5, 0],
				"attackInterval" : 24,
				"power"          : 700,
				"attackKind"     : "physics"
			};
			this.attackBackInfoDict["hit2_2"] = {
				"hitMaxCount"    : 99,
				"attackBackSpeed": [-5, 0],
				"attackInterval" : 999,
				"power"          : 700,
				"attackKind"     : "physics"
			};
			this.attackBackInfoDict["hit3"] = {
				"hitMaxCount"    : 99,
				"attackBackSpeed": [-4, 0],
				"attackInterval" : 999,
				"power"          : 800,
				"attackKind"     : "magic"
			};
			this.attackBackInfoDict["hit4"] = {
				"hitMaxCount"    : 99,
				"attackBackSpeed": [-4, 0],
				"attackInterval" : 999,
				"power"          : 600,
				"attackKind"     : "magic"
			};
			this.setAction("idle");
		}
		
		override protected function initBBDC():void
		{
			var _loc1_:* = null;
			var _loc2_:Array = BaseBitmapDataPool.getBitmapDataArrayByName("Monster305");
			if (_loc2_)
			{
				_loc1_ = {
					"name"  : "body",
					"source": _loc2_
				};
				bbdc = new BaseBitmapDataClip([_loc1_], 250, 250, new Point(0, 0));
				bbdc.setOffsetXY(15, -35);
				bbdc.setFrameStopCount([[2, 2, 2, 3, 2, 4], [4, 4, 4, 4], [15], [2, 2, 2, 2, 10], [2, 2, 3, 2, 2, 10], [2, 10], [2, 2, 2, 10]]);
				bbdc.setFrameCount([6, 4, 1, 5, 6, 2, 4]);
				bbdc.setEnterFrameCallBack(this.enterFrameFunc, this.exitFrameFunc);
				bbdc.setAddScriptWhenFrameOver(this.scriptFrameOverFunc);
				this.bodyContainer.addChild(bbdc);
				return;
			}
			throw new Error("Monster305--BitmapData Error!");
		}
		
		override protected function initCollideArea():void
		{
			this.colipse = ResUtil.getNewObj("ObjectBaseSprite") as Sprite;
			this.colipse.visible = false;
			this.addChild(this.colipse);
		}
		
		override public function setAction(param1:String):void
		{
			super.setAction(param1);
			var _loc2_:Point = this.bbdc.getCurPoint();
			switch (param1)
			{
				case "idle":
					if (_loc2_.y != 0)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(0);
					}
					this.bbdc.setState(param1);
					break;
				case "walk":
					if (_loc2_.y != 1)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(1);
					}
					this.bbdc.setState(param1);
					break;
				case "hurt":
					if (_loc2_.y != 2)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(2);
					}
					this.bbdc.setState(param1);
					break;
				case "hit1":
					if (_loc2_.y != 4)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(4);
					}
					this.bbdc.setState(param1);
					break;
				case "hit2":
					if (_loc2_.y != 5)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(5);
					}
					this.bbdc.setState(param1);
					break;
				case "hit3":
					if (_loc2_.y != 6)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(6);
					}
					this.bbdc.setState(param1);
					break;
				case "dead":
					if (_loc2_.y != 3)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(3);
					}
					this.bbdc.setState(param1);
			}
		}
		
		override protected function scriptFrameOverFunc(param1:int):void
		{
			var _loc2_:String = this.bbdc.getState();
			switch (_loc2_)
			{
				case "walk":
					this.bbdc.setFramePointX(0);
					break;
				case "idle":
					this.bbdc.setFramePointX(0);
					break;
				case "hit1":
					this.setAction("idle");
					break;
				case "hit2":
					this.setStatic();
					this.setAction("idle");
					break;
				case "hit3":
					this.setAction("idle");
					break;
				case "hurt":
					this.setStatic();
					this.setAction("idle");
					break;
				case "dead":
					this.dropAura();
					this.destroy();
			}
		}
		
		override protected function enterFrameFunc(param1:Point):void
		{
			var _loc2_:String = this.bbdc.getState();
			var _loc3_:uint = this.getBBDC().getDirect();
			switch (_loc2_)
			{
				case "hit1":
					if (param1.x == 2)
					{
						if (this.bbdc.getCurFrameCount() == 3)
						{
							this.doHi1(_loc3_);
							break;
						}
						break;
					}
					break;
				case "hit2":
					if (param1.x == 1)
					{
						if (this.bbdc.getCurFrameCount() == 8)
						{
							this.doHi2(_loc3_);
							break;
						}
						break;
					}
					break;
				case "hit3":
					if (param1.x == 3)
					{
						if (this.bbdc.getCurFrameCount() == 8)
						{
							this.doHi3(_loc3_);
							break;
						}
						break;
					}
			}
		}
		
		override protected function beforeSkill1Start():Boolean
		{
			return this.curAttackTarget != null;
		}
		
		override protected function beforeSkill2Start():Boolean
		{
			return Boolean(this.standInObj) && this.hasTarget();
		}
		
		override protected function beforeSkill3Start():Boolean
		{
			return true;
		}
		
		override protected function beforeSkill4Start():Boolean
		{
			var _loc1_:* = null;
			for each(_loc1_ in this.magicBulletArray)
			{
				if (_loc1_.getImcName() == "Monster305Bullet4_1")
				{
					return true;
				}
			}
			return false;
		}
		
		override protected function releSkill1():void
		{
			
			this.setInvincible(20);
			this.setAction("hit2");
			this.lastHit = "hit2";
		}
		
		override protected function releSkill2():void
		{
			
			this.setInvincible(20);
			this.setAction("hit3");
			this.lastHit = "hit3";
		}
		
		override protected function releSkill3():void
		{
			var _loc1_:FollowTargetBullet = new FollowTargetBullet("Monster305Bullet4_1");
			_loc1_.x = this.x;
			_loc1_.y = this.y + 40;
			_loc1_.setOwner(this);
			_loc1_.setDirect(1);
			_loc1_.setDisable();
			_loc1_.setIsDestroyWhenOwnerHurt(false);
			_loc1_.setIsDestroyWhenLastFrame(false);
			_loc1_.setDestroyInCount(gc.frameClips * 9);
			_loc1_.setAction("hit1");
			var _loc2_:uint = gc.gameScene.getChildIndex(this);
			gc.gameScene.addChildAt(_loc1_, _loc2_);
			this.magicBulletArray.push(_loc1_);
		}
		
		override protected function releSkill4():void
		{
			var _loc1_:* = null;
			var _loc2_:* = null;
			var _loc3_:uint = (this.getHpMax() - this.getHp()) * 0.002;
			this.attackBackInfoDict["hit4"] = {
				"hitMaxCount"    : 99,
				"attackBackSpeed": [-4, 0],
				"attackInterval" : 999,
				"power"          : _loc3_,
				"attackKind"     : "magic"
			};
			for each(_loc1_ in gc.team.getHeroArray())
			{
				if (AUtils.GetDisBetweenTwoObj(_loc1_, this) <= 175)
				{
					_loc2_ = new SpecialEffectBullet("Monster305Bullet4_2");
					_loc2_.x = _loc1_.x;
					_loc2_.y = this.y + 30;
					_loc2_.setRole(this);
					_loc2_.setDirect(1);
					_loc2_.setFuncWhenHit(this.cureHpWhenHit4Hit);
					_loc2_.setAction("hit4");
					gc.gameScene.addChild(_loc2_);
					this.magicBulletArray.push(_loc2_);
				}
			}
		}
		
		override protected function exitFrameFunc(param1:Point):void
		{
		}
		
		override protected function myIntelligence():void
		{
			if (!this.isBeAttacking())
			{
				super.myIntelligence();
			}
		}
		
		override public function destroy():void
		{
			var _loc1_:* = null;
			var _loc2_:* = null;
			var _loc3_:int = 0;
			var _loc4_:* = null;
			super.destroy();
			if (this.getHp() <= 0)
			{
				_loc1_ = ResUtil.getNewObj("GOGO");
				_loc1_.x = 860;
				_loc1_.y = 5 * 60;
				_loc1_.scaleX = 0.7;
				_loc1_.scaleY = 0.7;
				gc.gameInfo.addChild(_loc1_);
			}
		}
		
		private function cureHpWhenHit4Hit(param1:BaseBullet):void
		{
			this.cureHp((this.getHpMax() - this.getHp()) / 100);
		}
		
		private function doHi1(param1:uint):void
		{
			var _loc2_:SpecialEffectBullet = new SpecialEffectBullet("Monster305Bullet1");
			if (param1 == 0)
			{
				_loc2_.x = this.x - 140;
			}
			else
			{
				_loc2_.x = this.x + 140;
			}
			_loc2_.y = this.y;
			_loc2_.setOwner(this);
			_loc2_.setDirect(param1);
			_loc2_.setAction("hit1");
			gc.gameScene.addChild(_loc2_);
			this.magicBulletArray.push(_loc2_);
		}
		
		private function doHi2(param1:uint):void
		{
			var _loc2_:FollowTargetBullet = new FollowTargetBullet("Monster305Bullet2_1");
			_loc2_.x = this.x;
			_loc2_.y = this.y - 200;
			_loc2_.setOwner(this);
			_loc2_.setIsDestroyWhenOwnerHurt(false);
			_loc2_.setIsDestroyWhenLastFrame(false);
			_loc2_.setDestroyInCount(gc.frameClips * 12);
			_loc2_.setFuncWhenInCount(doHit2_2, 3, 0);
			_loc2_.setDirect(param1);
			_loc2_.setAction("hit2_1");
			gc.gameScene.addChild(_loc2_);
			this.magicBulletArray.push(_loc2_);
		}
		
		private function doHit2_2():void
		{
			var _loc1_:* = null;
			var _loc2_:* = null;
			var _loc3_:* = null;
			var _loc4_:* = null;
			if (!this.curAttackTarget)
			{
				return;
			}
			for each(_loc2_ in this.magicBulletArray)
			{
				if (_loc2_.getImcName() == "Monster305Bullet2_1")
				{
					_loc1_ = _loc2_;
					break;
				}
			}
			if (_loc1_)
			{
				_loc3_ = new EnemyMoveBullet("Monster305Bullet2_2");
				_loc3_.x = _loc1_.x;
				_loc3_.y = _loc1_.y;
				_loc3_.setRole(this);
				_loc4_ = McUtil.getTwoObjectAngle(_loc3_, this.curAttackTarget);
				_loc3_.setSpeed(Number(_loc4_.x) * 3, Number(_loc4_.y) * 3);
				_loc3_.setAddSpeed(_loc4_.x, _loc4_.y);
				_loc3_.setDistance(1000);
				_loc3_.setDestroyWhenLastFrame(false);
				_loc3_.setDirect(1);
				_loc3_.setAction("hit2_2");
				gc.gameScene.addChild(_loc3_);
				this.magicBulletArray.push(_loc3_);
			}
		}
		
		private function doHi3(param1:uint):void
		{
			if (Boolean(this.standInObj) && this.hasTarget())
			{
				var _loc2_:SpecialEffectBullet = new SpecialEffectBullet("Monster305Bullet3");
				_loc2_.x = this.curAttackTarget.x;
				_loc2_.y = 510;
				_loc2_.setOwner(this);
				_loc2_.setDirect(param1);
				_loc2_.setAction("hit3");
				gc.gameScene.addChild(_loc2_);
				this.magicBulletArray.push(_loc2_);
			}
		}
	}
}
*/
